import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig((userConfig) => {
  console.log('vite userConfig', userConfig)
  return {
    base: './',
    plugins: [vue(), vueJsx()],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
    server: {
      proxy: {
        '/apis': {
          target: 'http://10.54.42.134:8080',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/apis/, '')
        },
        '/orgimage': {
          target: 'http://10.54.42.134:8080',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/orgimage/, '')
        }
      }
    }
  }
})
